/*
 * HelpCenterFragment.java
 * business
 *
 * Created by SunDing on 2016/9/9.
 *
 * Copyright (c) 2016年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.ui.service.helpcenter;

import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ListView;

import com.yidiandao.business.R;
import com.yidiandao.business.base.SuperBaseFragment;
import com.yidiandao.business.ui.adapter.HelpCenterAdapter;
import com.yidiandao.business.ui.widget.listview.DisplayListItem;

import java.util.List;

/** 帮助中心 */
public class HelpCenterFragment extends SuperBaseFragment implements HelpCenterContract.View {

    private String TAG = HelpCenterFragment.class.getSimpleName();

    private Toolbar mToolbar;

    private HelpCenterContract.Presenter mPresenter;

    private ListView mListView;

    private HelpCenterAdapter mHelpCenterAdapter;

    public static HelpCenterFragment getInstance() {
        return new HelpCenterFragment();
    }

    @Override
    protected void initViews() {
        mToolbar = (Toolbar) mRootView.findViewById(R.id.toolbar);

        mListView = (ListView) mRootView.findViewById(R.id.list_view);
        mHelpCenterAdapter = new HelpCenterAdapter(mActivity);
        mListView.setAdapter(mHelpCenterAdapter);

        initEvent();
    }

    @Override
    protected void startLoadData() {
        mPresenter.start();
    }

    private void initEvent() {
        mToolbar.setNavigationOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        mActivity.finish();
                    }
                });
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_help_center;
    }

    @Override
    public void setPresenter(HelpCenterContract.Presenter presenter) {
        mPresenter = presenter;
    }

    @Override
    public String getPagerTag() {
        return TAG;
    }

    @Override
    public void showToast(String text) {
    }

    @Override
    public void setDisplayListItem(List<DisplayListItem> displayListItems) {
        mHelpCenterAdapter.setData(displayListItems);
    }

    @Override
    public void refreshContent(int result) {
        superRefreshLayoutState(result);
    }

    @Override
    public int checkResultObject(Object resultObject) {
        return superCheckListState(resultObject);
    }
}
